<include file="public@header"/>
</head>
<body style="background-color: #E5F3E6">
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
    <!--equipment 不能写成 equipment  否则会报控制器不存在-->
        <li><a href="{:url('equipment/equipmentIndex')}">设备</a></li>
		<li  class="active"><a href="{:url('equipment/equipmentAdd')}">添加设备</a></li></li>
    </ul>
    <!-- js-ajax-form-->
    <form class="form-horizontal margin-top-20" action="{:url('equipment/equipmentAddPost')}" method="post">
        <div class="form-group">
            <label for="input-equipmentCode" class="col-sm-2 control-label"><span class="form-required">*</span>设备编号</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-equipmentCode" name="equipmentCode">
            </div>
        </div><div class="form-group">
            <label for="input-equipmentName" class="col-sm-2 control-label"><span class="form-required">*</span>设备名称</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-equipmentName" name="equipmentName">
            </div>
        </div>
		<div class="form-group">
            <label for="input-equimentType" class="col-sm-2 control-label"><span class="form-required">*</span>设备类型</label>
            <div class="col-md-6 col-sm-10">
				 <select class="form-control" name="equimentType" id="equimentType">
                    <foreach name="result_et" item="vo">
                        <option  value="{$vo.equipmentTypeID}">{$vo.equipmentTypeName}</option>
                    </foreach>
                </select>
            </div>
        </div>
		<div class="form-group">
            <label for="input-departID" class="col-sm-2 control-label"><span class="form-required">*</span>所属部门</label>
            <div class="col-md-6 col-sm-10">
                <select class="form-control" onchange="searchStation()" name="departID" id="input-depart_id">
                    <option value="0">作为一级部门</option>{$select_category}
                </select>
            </div>
        </div>
		<!-- <div class="form-group"> -->
            <!-- <label for="input-stationID" class="col-sm-2 control-label"><span class="form-required">*</span>所在岗位</label> -->
            <!-- <div class="col-md-6 col-sm-10"> -->
                <!-- <select class="form-control" name="equipmentPlace" id="select_station"> -->
                 
                <!-- </select> -->
            <!-- </div> -->
        <!-- </div> -->
		<div class="form-group">
            <label for="input-isSpecial" class="col-sm-2 control-label"><span class="form-required">*</span>是否特种设备</label>
            <div class="col-md-6 col-sm-10">
				<select class="form-control" name="isSpecial" id="input-isSpecial">
						<option  value='0'>否</option>
                        <option  value='1'>是</option>
	
                </select>
            </div>
        </div>
		
		<div class="form-group">
            <label for="input-memos" class="col-sm-2 control-label"><span class="form-required">*</span>备注</label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-memos" name="memos">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript">
        /*组织机构下拉框选择事件*/
        function searchStation() {
          //获取组织机构select 对象
           var selectDepartment = document.getElementById('input-depart_id');  
           //拿到选中项的索引：
           var index=selectDepartment.selectedIndex;
           //拿到选中项options的value：
           var departmentValue = selectDepartment.options[index].value;
           
           //拿到选中项options的text：
           //var departmentStr = (selectDepartment.options[index].text);
           var departmentText = selectDepartment.options[index].text;
           <!-- console.log(departmentValue); -->
           $.ajax({
               // url:"/index.php/admin/company/ajaxStation",
                url:"/admin/company/ajaxStation",
                data:{stationStr:departmentValue},
                type:"get",
                dataType:"json",
                success: function(data){
                    console.log(data);
                    $("#select_station").find("option").remove();
                     // $("#select_station").append("<option value=''>请选择</option>");
                    //动态给select 赋值
                    for(var i=0;i<data.length;i++){
                       $("#select_station").append("<option id = '"+ data[i]["stationID"]+"' value='"+ data[i]["stationID"]+"'>"+ data[i]["stationName"]+"</option>");
                    } 
                }
            });
        }
    </script>
</body>
</html>